package com.lanou.renrenxin.scanmodel;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import android.widget.ImageView;

import com.easemob.chat.EMChatManager;
import com.lanou.renrenxin.R;

/**
 * Created by dllo on 16/3/21.
 */
public class CreateQRCodeAty extends AppCompatActivity {
    private AppCompatTextView etContent;
    private ImageView imgShow;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_create2dcode);

        etContent = (AppCompatTextView) findViewById(R.id.input_content);
        imgShow = (ImageView) findViewById(R.id.img_show);
        etContent.setText(EMChatManager.getInstance().getCurrentUser());

        String content = etContent.getText().toString();
        createQRImage(content);
    }

    private void createQRImage(String content){
        CreateQRCode.createQRImage(content, "test", new CreateQRCode.OnCreateQRListener() {
            @Override
            public void onSuccess(Bitmap qrImage) {
                imgShow.setImageBitmap(qrImage);
            }
        });
    }

    public void back(View view){
        finish();
    }
}